package cn.iocoder.yudao.module.shop.revenue.mq;

import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.module.api.shop.revenue.message.RevenueCancelMessage;
import cn.iocoder.yudao.module.api.shop.revenue.message.RevenueUnfreezeMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 商家营收 事件生产者
 *
 * @author 山野羡民
 */
@Slf4j
@Component
public class RevenueProducer {

    /**
     * 发送 {@link RevenueUnfreezeMessage} 消息
     *
     * @param shopId 店铺编号
     * @param tradeNo 交易单号
     * @param payPrice 实付金额
     * @param settlementMoney 结算金额
     */
    public void sendRevenueUnfreezeMessage(Long shopId, String tradeNo, Integer payPrice, Integer settlementMoney) {
        log.info("[sendRevenueUnfreezeMessage][shopId({}) tradeNo({}) payPrice({}) settlementMoney({})]", shopId, tradeNo, payPrice, settlementMoney);
        SpringUtil.getApplicationContext().publishEvent(new RevenueUnfreezeMessage(shopId, tradeNo, payPrice, settlementMoney));
    }

    /**
     * 发送 {@link RevenueCancelMessage} 消息
     *
     * @param shopId 店铺编号
     * @param tradeNo 交易单号
     * @param payPrice 实付金额
     * @param settlementMoney 结算金额
     */
    public void sendRevenueCancelMessage(Long shopId, String tradeNo, Integer payPrice, Integer settlementMoney) {
        log.info("[sendRevenueCancelMessage][shopId({}) tradeNo({}) payPrice({}) settlementMoney({})]", shopId, tradeNo, payPrice, settlementMoney);
        SpringUtil.getApplicationContext().publishEvent(new RevenueCancelMessage(shopId, tradeNo, payPrice, settlementMoney));
    }

}
